//
//  OrderListViewModel.m
//  didacar
//
//  Created by 度周末网络-王腾 on 15/12/25.
//  Copyright © 2015年 dzmmac. All rights reserved.
//

#import "OrderListViewModel.h"
#import "ResponseOrderListModel.h"

@implementation OrderListViewModel

-(id)init{
    self.orderList = [[NSMutableArray alloc ] init];
    return [super init];
}

/**
 *  加载订单列表数据
 *
 *  @param resultBlock 回调
 */
-(void)loadOrderListData:(DealDataResultBlock)resultBlock{

    NSMutableDictionary *postDic =  [[NSMutableDictionary alloc ] init];
    [postDic setObj:USERINFOManager.getUserInfo.MemberId forKey:@"MemberId"];
    [postDic setObj:@(self.pageIndex).stringValue forKey:@"PageIndex"];
    [postDic setObj:@(self.pageCount).stringValue forKey:@"PageSize"];
    
    WEAKSELF
    [[BaseHttpRequest sharedInstance] sendRequestToPost:OrderList withData:postDic alertMessage:@"" success:^(NSDictionary *dicData) {
        
        if (weakSelf.pageIndex == 1) {
            [weakSelf.orderList removeAllObjects];
        }
        
        for (NSDictionary *dic in dicData[@"TicketOrderList"]) {
            [weakSelf.orderList addObject:[[ResponseOrderListModel alloc ] initWithDictionary:dic]];
        }
        [weakSelf configIsLoadMore:dicData[@"TicketOrderList"]];
        resultBlock(1,nil,nil);
        
    } error:^(NSString *errorMsg) {
         resultBlock(0,nil,nil);
    }];

}

@end
